# Compile
FROM registry.cn-hangzhou.aliyuncs.com/gebilaoyu/rust:1.79.0 AS compiler


WORKDIR /dnf-admin-rs
ENV RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
ENV RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
ADD . /api /dnf-admin-rs/api/
ADD . /common /dnf-admin-rs/common/
ADD . /entity /dnf-admin-rs/entity/
ADD . /migration /dnf-admin-rs/migration/
ADD . /model /dnf-admin-rs/model/
ADD . /security /dnf-admin-rs/security/
ADD . /service /dnf-admin-rs/service/
ADD . /src /dnf-admin-rs/src/
COPY . /config.yaml /dnf-admin-rs/
COPY . /Cargo.toml /dnf-admin-rs/
RUN cargo build --release


# Run
FROM registry.cn-hangzhou.aliyuncs.com/gebilaoyu/ubuntu:24.10

COPY --from=compiler /dnf-admin-rs/target/release/dnf-admin-rs /apps/
COPY --from=compiler /dnf-admin-rs/config.yaml /apps/

#ENV HOST=0.0.0.0
#ENV PORT=8080
#ENV RUST_LOG=info
#ENV DATABASE_URL=sqlite://db.sqlite?mode=rwc

WORKDIR /apps
CMD ["./dnf-admin-rs"]
